﻿using MediatR;
using T_Material.API.Application.Commands.PurchaseCommand;
using T_Material.API.Application.Commands.RequisitionCommand;
using T_Material.Infrastructure.ImpI;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.RequisitionHandlers
{
    public class RequisitionDeleteCommandHandler : IRequestHandler<RequisitionDeleteCommand, int>
    {
        private readonly IRequisitionRepository requisitionRepository;
        public RequisitionDeleteCommandHandler(IRequisitionRepository requisitionRepository)
        {
            this.requisitionRepository = requisitionRepository;
        }
        public async Task<int> Handle(RequisitionDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await requisitionRepository.GetModelAs(request.Id);
            info.IsDel = true;
            return await requisitionRepository.Update(info);
        }
    }
}
